/**
 * 模糊综合评价法
 * */
public class FuzzyAlgorithm {




    //矩阵相乘
    public Double[] matrixMultiplication(Double[] weight, Double[][] second, Double[] third){

            for (int i=0;i< 5;i++){
                for (int j=0;j<5;j++){
                    third[i] = third[i]+weight[j] * second[j][i];

                }
            }
        return third;
    }


        //矩阵的转置
        public void matrixTranspose(Double first[][], Double second[][]) {

            for(int i = 0;i<first.length;i++) {
                for(int j =0;j<first.length;j++) {
                    second[i][j] = first[j][i];
                }
            }
        }

    /**
     * 各项属性的隶属度函数
     * */


    //距离的隶属度函数
    public double distanceFunction(double distance){
        double distance_value = 0;
        if(distance<1.0){
            distance_value = 1.0;
        } else if (distance>=1.0&distance<=5.0) {
            distance_value = (10.0-distance)/9.0;
        }else if(distance>5.0) {
            distance_value = 0;
        }

        return distance_value;
    }


    //速度的隶属度函数
    public double speedFunction(double speed){
        double speed_value = 0;
        if (speed<5.0){
            speed_value = 0;
        } else if (speed>=5.0&speed<=35.0) {
            speed_value = (speed_value-5.0)/30.0;

        }else if(speed>35.0){
            speed_value = 1.0;
        }
        return speed_value;

    }

    //高度的隶属度函数
    public double altitudeFunction(double altitude){
        double altitude_value = 0;
        if (altitude<50.0){
            altitude_value = 1.0;
        } else if (altitude>=50.0&altitude<1000) {
            altitude_value = (1000.0-altitude)/950.0;

        } else if (altitude>=1000.0) {
            altitude_value = 0;

        }
        return altitude_value;

    }


    //归属(阵营)的隶属度函数
    public double campFunction(String camp){
        double camp_value = 0;
        if (camp.equals("敌方")){
            camp_value = 1;
        } else if (camp.equals("未知")) {
            camp_value = 0.8;

        }
        return camp_value;
    }


    //用途的隶属度函数
    public double typeFunction(String type ){
        double type_value = 0;
        if (type.equals("攻击型")){
            type_value = 1;
        } else if (type.equals("侦查型")) {
            type_value = 0.7;

        } else if (type.equals("民用型")) {
            type_value = 0.5;
        }
        return type_value;
    }









    }


